import pygame
# Start button, difficulty selection button, pause button, resume button, exit game button
# Difficulty setting: pratice (training mode), simply (simple mode), hard (hard mode)
class Button():
    def __init__(self, screen, ai_settings, msg, button_color, font_color,pos, size):
        # Initialize button properties
        self.screen = screen
        self.screen_rect = screen.get_rect()

        # Set the size and other properties of the button
        self.width, self.height = size
        self.button_color = button_color
        self.text_color = font_color
        self.font = pygame.font.SysFont("arial", 40)

        #  Create the rect object of the button
        # self.rect = pygame.Rect(0, 0, self.width, self.height)
        #  Button centered
        # self.rect.center = self.screen_rect.center

        # Create the rect object of the button
        self.rect = pygame.Rect(pos[0], pos[1], self.width, self.height)

        # The label of the button only needs to be created once
        self.prep_msg(msg)

    def prep_msg(self, msg):
        # Render msg as an image and center it on the button
        self.msg_image = self.font.render(msg, True, self.text_color, self.button_color)
        self.msg_image_rect = self.msg_image.get_rect()
        self.msg_image_rect.center = self.rect.center

    def draw_button(self):
        # Draw a text filled with color
        self.screen.fill(self.button_color, self.rect)
        self.screen.blit(self.msg_image, self.msg_image_rect)

#Draw control buttons
class control_button():
    def __init__(self,screen,ai_settings,pos):
        self.screen=screen
        self.ai_settings=ai_settings
        self.pos=pos
    def blitButton(self,screen,image,transformSize,imgPos):
        self.image = pygame.image.load(image).convert_alpha()
        # Adjust button size
        self.image = pygame.transform.scale(self.image,transformSize)
        # self.image = pygame.transform.scale(self.image, (50, 50))
        self.rect = self.image.get_rect()
        self.rect.left, self.rect.top = imgPos[0], imgPos[1]
        screen.blit(self.image, self.rect)

    # def blitButton2(self,screen, image):
    #     self.image = pygame.image.load(image).convert_alpha()
    #     # Adjust button size
    #     self.image = pygame.transform.scale(self.image, (200, 200))
    #     self.rect = self.image.get_rect()
    #     self.rect.left, self.rect.top = self.pos[0], self.pos[1]
    #     screen.blit(self.image, self.rect)